from django.db import models
from django.utils import timezone

# Create your models here.
class UserInfo(models.Model):
    username = models.CharField(verbose_name="用户名", max_length=32)
    email = models.EmailField(verbose_name="邮箱", max_length=32)
    mobile_phone = models.CharField(verbose_name="手机号", max_length=32)
    password = models.CharField(verbose_name="密码", max_length=32)
    lasttime = models.DateTimeField(verbose_name="最后一次登录失败的时间",null=True,blank=True,default=timezone.now)
    failcount = models.IntegerField(verbose_name="连续错误次数",default=0)


class Block(models.Model):
    hash = models.CharField(verbose_name="标识", max_length=64)
    order_id = models.CharField(verbose_name="订单号", max_length=32, null=False)
    customer_id = models.CharField(verbose_name="客户号", max_length=32, null=False)
    product_id = models.CharField(verbose_name="产品号", max_length=32, null=False)
    block = models.TextField(verbose_name='区块',max_length=1000)

class Order(models.Model):
    order_id = models.CharField(verbose_name="订单号", max_length=100, null=False)
    order_date = models.CharField(verbose_name="订单日期", max_length=100, null=False)
    ship_date = models.CharField(verbose_name="出货日期", max_length=100, null=False)
    ship_mode = models.CharField(verbose_name="运输模式", max_length=100, null=False)
    customer_id = models.CharField(verbose_name="客户号", max_length=100, null=False)
    customer_name = models.CharField(verbose_name="客户名", max_length=100, null=False)
    segment = models.CharField(verbose_name="部门", max_length=100, null=False)
    country = models.CharField(verbose_name="国家", max_length=100, null=False)
    city = models.CharField(verbose_name="城市", max_length=100, null=False)
    state = models.CharField(verbose_name="州", max_length=100, null=False)
    postal_code = models.CharField(verbose_name="邮政编码", max_length=100, null=False)
    region = models.CharField(verbose_name="区域", max_length=100, null=False)
    product_id = models.CharField(verbose_name="产品号", max_length=100, null=False)
    category = models.CharField(verbose_name="类别", max_length=100, null=False)
    sub_category = models.CharField(verbose_name="子类别", max_length=100, null=False)
    product_name = models.CharField(verbose_name="产品名", max_length=100, null=False)
    sales = models.CharField(verbose_name="出售", max_length=100, null=False)
    is_block = models.IntegerField(verbose_name='是否添加到区块链',default=0)

class CustomerInfo(models.Model):
    username = models.CharField(verbose_name="用户名", max_length=32)
    password = models.CharField(verbose_name="密码", max_length=32)
    is_first = models.SmallIntegerField(verbose_name="是否是第一次登录",default=1)